using System.Security.Cryptography.X509Certificates;
using Services.Identity.Domain.ValueObject;
using Services.Initial.PublicProject.PublicClass.ExtensionException;

namespace Services.Identity.Domain.Entities;
public class UserPermission
{
    public int Id { get; private set; }
    public PermissionNameAndRouter PermissionNameAndRouter { get;private set; }
    public List<Role> Roles { get; set; } = [];
    private UserPermission() { }
    public static UserPermission Create(string permissionName, string routerName)
    {
        if (!string.IsNullOrWhiteSpace(permissionName))
        {
            var permission = new UserPermission { PermissionNameAndRouter = new PermissionNameAndRouter(permissionName, routerName) };
            return permission;
        }
        else
        {
            throw new ExceptionWithStatus(System.Net.HttpStatusCode.BadRequest, "Permission name can not be empty");
        }
    }
}